import { defineStore } from "pinia";

// 用户登录状态管理
export const useUserStore = defineStore('user', () => {
    const user_id = ref(null);      // uid
    const user_name = ref(null);    // 账号名

    function login(id, name) {
        // 保存属性
        user_id.value = id;
        user_name.value = name;
    }

    function logout() {
        // 清除属性
        user_id.value = null;
        user_name.value = null;
    }

    return {user_id, user_name, login, logout}
},
{
    persist: {
        storage: sessionStorage
    }
});